package com.king.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 路由定位器
 * @author king
 * @date 2020/9/14 0:19
 */
@Configuration
public class GateWayConfig {

    /**
     * 路由转发配置
     * @param builder 路由定位器生成器
     * @return 定位转发
     */
    @Bean
    public RouteLocator routes(RouteLocatorBuilder builder){
        return builder.routes()
                // id
                .route("routeLocator",
                // 配置规则
                r -> r.path("/guonei")
                // 路由转发
                .uri("http://news.baidu.com/guonei")).build();
    }
}
